package com.jjb.www.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.hjq.shape.layout.ShapeLinearLayout;
import com.hjq.shape.view.ShapeTextView;
import com.jjb.www.R;
import com.jjb.www.app.AppAdapter;
import com.jjb.www.http.api.UserPaperV2ListApi;

/**
 *    author : Android CRG
 *    github : https://github.com/getActivity/AndroidProject
 *    time   : 2018/11/05
 *    desc   : 可进行拷贝的副本
 */
public final class CpAdapter extends AppAdapter<UserPaperV2ListApi.Bean> {

    public CpAdapter(Context context) {
        super(context);
    }


    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder();
    }

    private final class ViewHolder extends AppAdapter<?>.ViewHolder {
        private ShapeLinearLayout mLlView;
        private ShapeTextView mTvTitle;
        private ShapeTextView mTvType;


        private ViewHolder() {
            super(R.layout.item_cp);
            mLlView = findViewById(R.id.ll_view);
            mTvTitle = findViewById(R.id.tv_title);
            mTvType = findViewById(R.id.tv_type);

        }

        @Override
        public void onBindView(int position) {
            UserPaperV2ListApi.Bean bean = getItem(position);
            mTvTitle.setText(bean.getName());
            if (bean.getStatus()==1){
                //专业知识
                mTvType.setText("专业知识");
                mLlView.setBackgroundResource(R.mipmap.icon_mnks_1);
            }else {
                mTvType.setText("通用知识");
                mLlView.setBackgroundResource(R.mipmap.icon_mnks2);
            }
        }
    }
}